package operation;

import book.Book;
import book.BookList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-02-10
 * Time: 16:32
 */
public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("新增图书！");
        System.out.println("请输入图书的名字：");
        String name = scanner.nextLine();
        System.out.println("请输入图书的作者：");
        String author = scanner.nextLine();
        System.out.println("请输入图书的类型：");
        String type = scanner.nextLine();
        System.out.println("请输入图书的价格：");
        double price = scanner.nextDouble();

        Book book = new Book(name,author,type,price);
        int size = bookList.getUserSize();
        bookList.setBook(size,book);
        bookList.setUserSize(size+1);
        System.out.println("图书新增成功！");
    }
}
